@echo off
echo 正在安装Android SDK平台...

REM 设置Android SDK路径
set "ANDROID_SDK_PATH=C:\Users\%USERNAME%\AppData\Local\Android\Sdk"
set "SDKMANAGER=%ANDROID_SDK_PATH%\cmdline-tools\latest\bin\sdkmanager.bat"

REM 检查SDK Manager是否存在
if not exist "%SDKMANAGER%" (
    echo 错误: 找不到SDK Manager
    echo 请确保已安装Android Studio和Android SDK
    echo SDK Manager路径: %SDKMANAGER%
    pause
    exit /b 1
)

echo 正在安装Android API 33 (Android 13)...
"%SDKMANAGER%" "platforms;android-33"

echo 正在安装Android API 32 (Android 12L)...
"%SDKMANAGER%" "platforms;android-32"

echo 正在安装Android API 31 (Android 12)...
"%SDKMANAGER%" "platforms;android-31"

echo 正在安装Android API 30 (Android 11)...
"%SDKMANAGER%" "platforms;android-30"

echo 正在安装Android API 29 (Android 10)...
"%SDKMANAGER%" "platforms;android-29"

echo 正在安装Android API 28 (Android 9)...
"%SDKMANAGER%" "platforms;android-28"

echo 正在安装Android API 27 (Android 8.1)...
"%SDKMANAGER%" "platforms;android-27"

echo 正在安装Android API 26 (Android 8.0)...
"%SDKMANAGER%" "platforms;android-26"

echo 正在安装Android API 25 (Android 7.1)...
"%SDKMANAGER%" "platforms;android-25"

echo 正在安装Android API 24 (Android 7.0)...
"%SDKMANAGER%" "platforms;android-24"

echo 正在安装Android API 23 (Android 6.0)...
"%SDKMANAGER%" "platforms;android-23"

echo 正在安装Android API 22 (Android 5.1)...
"%SDKMANAGER%" "platforms;android-22"

echo 正在安装Android API 21 (Android 5.0)...
"%SDKMANAGER%" "platforms;android-21"

echo 正在安装Android API 20 (Android 4.4W)...
"%SDKMANAGER%" "platforms;android-20"

echo 正在安装Android API 19 (Android 4.4)...
"%SDKMANAGER%" "platforms;android-19"

echo 正在安装Android API 18 (Android 4.3)...
"%SDKMANAGER%" "platforms;android-18"

echo 正在安装Android API 17 (Android 4.2)...
"%SDKMANAGER%" "platforms;android-17"

echo 正在安装Android API 16 (Android 4.1)...
"%SDKMANAGER%" "platforms;android-16"

echo.
echo 安装完成！现在可以构建支持所有Android版本的应用了。
echo.
echo 运行以下命令来构建应用：
echo   gradlew assembleRelease
echo.
pause 